<html lang='zh-CN' xml:lang='zh-CN' xmlns='http://www.w3.org/1999/xhtml'>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

        <!-- blueprint CSS framework -->
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/screen.css" media="screen, projection" />
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/print.css" media="print" />
        <!--[if lt IE 8]>
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/ie.css" media="screen, projection" />
        <![endif]-->

        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/main.css" />
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/form.css" />

        <title><?php echo CHtml::encode($this->pageTitle); ?></title>
        <?php
            //线上的debug是关闭的，所以一debug来判断当前是测试环境还是生产环境
            //此处是百度统计代码，在测试环境中不输出此段代码
            if (!defined('YII_DEBUG')) {
        ?>
        <script>
            var _hmt = _hmt || [];
            (function() {
                var hm = document.createElement("script");
                hm.src = "//hm.baidu.com/hm.js?75426470f798aa2393b00eb6372c3f95";
                var s = document.getElementsByTagName("script")[0];
                s.parentNode.insertBefore(hm, s);
            })();
        </script>
        <?php
            }
        ?>

        <?php
            //syntaxhighlighter代码高亮显示需要加载的js/css====================begin
            Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl . "/js/syntaxhighlighter/styles/shCoreDefault.css");
            Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/js/syntaxhighlighter/scripts/shCore.js');
            Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/js/syntaxhighlighter/scripts/shAutoloader.js');
        ?>
        <script>
            $(document).ready(function() {
                function path()
                {
                    var args = arguments, result = [];
                    for(var i = 0; i < args.length; i++)
                        result.push(args[i].replace('@', '<?php echo Yii::app()->baseUrl . '/js/syntaxhighlighter/scripts/'; ?>'));
                    return result;
                };

                SyntaxHighlighter.autoloader.apply(null, path(
                    'applescript            @shBrushAppleScript.js',
                    'actionscript3 as3      @shBrushAS3.js',
                    'bash shell             @shBrushBash.js',
                    'coldfusion cf          @shBrushColdFusion.js',
                    'cpp c                  @shBrushCpp.js',
                    'c# c-sharp csharp      @shBrushCSharp.js',
                    'css                    @shBrushCss.js',
                    'delphi pascal          @shBrushDelphi.js',
                    'diff patch pas         @shBrushDiff.js',
                    'erl erlang             @shBrushErlang.js',
                    'groovy                 @shBrushGroovy.js',
                    'java                   @shBrushJava.js',
                    'jfx javafx             @shBrushJavaFX.js',
                    'js jscript javascript  @shBrushJScript.js',
                    'perl pl                @shBrushPerl.js',
                    'php                    @shBrushPhp.js',
                    'text plain             @shBrushPlain.js',
                    'py python              @shBrushPython.js',
                    'ruby rails ror rb      @shBrushRuby.js',
                    'sass scss              @shBrushSass.js',
                    'scala                  @shBrushScala.js',
                    'sql                    @shBrushSql.js',
                    'vb vbnet               @shBrushVb.js',
                    'xml xhtml xslt html    @shBrushXml.js'
                ));
                SyntaxHighlighter.all();
            });
        </script>
        <?php // syntaxhighlighter代码高亮显示需要加载的js/css====================end ?>

    </head>

    <body>

        <div class="container" id="page">

            <div id="header">
                <div id="logo"><?php echo CHtml::encode(Yii::app()->name); ?></div>
            </div><!-- header -->

            <div id="mainmenu">
                <?php
                $this->widget('zii.widgets.CMenu', array(
                    'items' => array(
                        array('label' => '时间轴', 'url' => array('site/index')),
                        array('label' => '博文', 'url' => array('post/index')),
                        array('label' => '关于', 'url' => array('site/page', 'view' => 'about')),
                        array('label' => '联系我们', 'url' => array('site/contact')),
                        array('label' => '登陆', 'url' => array('site/login'), 'visible' => Yii::app()->user->isGuest),
                        array('label' => '修改密码', 'url' => array('user/changePwd'), 'visible' => !Yii::app()->user->isGuest),
                        array('label' => '添加文章', 'url' => array('post/create'), 'visible' => !Yii::app()->user->isGuest),
                        array('label' => '管理文章', 'url' => array('post/admin'), 'visible' => Yii::app()->user->name == 'admin'),
                        array('label' => '更新时间轴', 'url' => array('user/reTimeLine'), 'visible' => Yii::app()->user->name == 'admin'),
                        array('label' => '退出 (' . Yii::app()->user->name . ')', 'url' => array('site/logout'), 'visible' => !Yii::app()->user->isGuest),
                    ),
                ));
                ?>
            </div><!-- mainmenu -->

            <?php
            $this->widget('zii.widgets.CBreadcrumbs', array(
                'links' => $this->breadcrumbs,
            ));
            ?><!-- breadcrumbs -->

            <?php echo $content; ?>

            <div id="footer">
                Copyright &copy; <?php echo date('Y'); ?> by My Company.<br/>
                All Rights Reserved.<br/>
                <?php echo Yii::t('yii', 'Powered by {yii}.', array('{yii}' => '<a href="http://www.liuxos.com/" rel="external">WE Blog</a>')); ?>
            </div><!-- footer -->

        </div><!-- page -->

        <style>
            #gototop{width:80px;height:60px;background:url('<?php echo Yii::app()->baseUrl; ?>/images/top.png') 0px 0px no-repeat;position:fixed;right:5px;bottom:250px;cursor:pointer;}
            #gototop:hover{background:url('<?php echo Yii::app()->baseUrl; ?>/images/top.png') 0px -61px no-repeat;}
        </style>
        <div id="gototop" title="回到顶部"></div>
        <script>
            $("#gototop").click(function(){
                $("html, body").animate({scrollTop: "0px"},600);
            })
        </script>
        <style>
            .right {float: right;position:fixed;right:0px;bottom:0px;}
        </style>
        <div class="right">
            <iframe id="dog" style="width: 320px;height: 245px;" src=""></iframe>
        </div>
        <script>
            setTimeout(function() {
                $('#dog').attr('src', '<?php echo Yii::app()->createUrl('site/dog'); ?>');
            },
            5000)
        </script>
        <?php
            //更新时间轴的提示信息
            if (Yii::app()->user->hasFlash('reTimeLine')) {
                echo '<script>alert("'.Yii::app()->user->getFlash('reTimeLine','时间轴更新失败').'");</script>';
            }
        ?>
    </body>
</html>